/*
 * Creator:     ML
 * CreatDate:   2019-09-03
 * descripts：  拆分账单
*/
import React from 'react';
import { Form, Row, Col, Input, Select, Button, DatePicker,TimePicker,Checkbox, Modal,Card,Table, Icon, Pagination, message, Steps, Divider, Tooltip } from 'antd';
import moment from 'moment';
import { $http } from '../../containers/config/https';
import store from '../../store';
import './charges/style/style.less';
import TipHeader from './charges/component/TipHeader'

const FormItem = Form.Item;
const Option = Select.Option;
const confirm = Modal.confirm;
const userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}

const formItemLayout = { // label 和input宽度
  labelCol: { span: 8 },
  wrapperCol: { span: 14 },
}

const formItemLayoutDoctor = { // label 和input宽度
    labelCol: { span: 8 },
    wrapperCol: { span: 16 },
  }
  
  const formItemcardStatus = {
    labelCol: { span: 7 },
    wrapperCol: { span: 14 },
  }
  
  const formItemNumber = {
    labelCol: { span: 9 },
    wrapperCol: { span: 14 },
  }
  
  const formItemMoney = {
    labelCol: { span: 11 },
    wrapperCol: { span: 11 },
  }
  
  const formItemCard = {
    labelCol: { span: 10 },
    wrapperCol: { span: 23 },
  }
  
  const formItemNewCard = {
    labelCol: { span: 8 },
    wrapperCol: { span: 16 },
  }
  
  const formItemNew = {
    labelCol: { span: 2 },
    wrapperCol: { span: 16 },
  }
  
  const formItemNewButton = {
    labelCol: { span: 2 },
    wrapperCol: { span: 22 },
  }

const SplitBills = Form.create()(
  class SplitBills extends React.Component {
    constructor(props) {
      super(props)
      this.state = {
        loading: false,
        visible: false,
        visibleLog: false,//日志变更
        total: 0,//表格总数据
        leftData: [],//待选 左侧
        rightData: [],//已选 右侧
        rowIds: '',//表格行选中 医嘱项弹窗
        medicalAdviceData: [],//绑定卡 卡关联数据
        values: {},//查询条件数据
        visibleMedicalAdvice: false,//医嘱项搜索成功弹窗
        readLoading: false,//补卡loading
        searchLoading: false,//查询请求
        initpatCardID: '',//绑定卡时类型
        rowId: '',//表格行选中 卡关联
        logBeforeCardNo: "",

        disBill:true,//是否可确认拆分
        disAdd:true,//选择添加
        disCancel:true,//取消添加
        baseParms: [],//下拉框数据
        medAGenArr:[],//医嘱大类
        medASubArr:[],//医嘱子类
        medADocArr:[],//医生医嘱
        openDepArr:[],//开单科室
        babyArr:[],//孩子们
        selectedRow_left:[],//左侧点击添加的项目
        selectedRow_right:[],//右侧点击添加的项目
        page:1, 
        pageSize:10,
        medItemValue:"",//医嘱项搜索内容
        babyId:[],//选择孩子id
        
        totalRight:0,//右侧表格总数据
        pageRight:1, //右侧表格页数
        pageSizeRight:10,//右侧页面显示条数
        totalTop:0,//上方表格总数据
        pageTop:1, //上方表格页数
        pageSizeTop:10,//上方页面显示条数
        leftMoney:0,//左侧待选金额
        rightMoney:0,//右侧待选金额
        userInfo:{},//用户信息

      }
      this.bindCardType = React.createRef();
  
    }
    componentDidMount() {
      let self = this
      // 初始化设置table的高度以及表体的高度
      document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y + 'px';
      let box = document.querySelector(".department-header");
      if(box){ //此处在加一层判断，更加严密，如果box存在的情况下获取
        this.setState({headerHeight: box.offsetHeight})
      }
    this.getBillsByMed()
    this.getBillsSelect()
    this.getOpenSelect()
    this.getDoctOrdSelect()
    this.getBabyArr()
    this.getRightChecked()
    }
    //获取下拉框数据 医嘱大类 子类
    getBillsSelect=()=>{
      let data = {}
      data = {
        params: [{
          hospID:userData.hospID,
          tableNameStr:""
        }],
      }
      $http.post('urlS', this, {
        code: '05100132',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
           this.setState({
            medAGenArr:res.ordCatData,
            medASubArr:res.ordSubCatData,
           })
          }
        },
      })
    }
    //获取下拉框数据 开单科室
    getOpenSelect=()=>{
      let data = {}
      data = {
        params: [{
          admID:sessionStorage.patientData ? JSON.parse(sessionStorage.patientData).admID:"",
        }],
      }
      $http.post('urlS', this, {
        code: '05100141',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
           this.setState({
            openDepArr:res.data
           })
          }
        },
      })
    }
    //获取下拉框数据 医生医嘱
    getDoctOrdSelect=()=>{
      let data = {}
      data = {
        params: [{
          // admID:"12055"
          admID:sessionStorage.patientData ? JSON.parse(sessionStorage.patientData).admID:"",
        }],
      }
      $http.post('urlS', this, {
        code: '05300004',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
           this.setState({
            medADocArr:res.data
           })
          }
        },
      })
    }
    //获取婴儿就诊信息
    getBabyArr=()=>{
      let data = {}
      data = {
        params: [{
          // admID:"12055"
          admID:sessionStorage.patientData ? JSON.parse(sessionStorage.patientData).admID:"",
        }],
      }
      $http.post('urlS', this, {
        code: '05300003',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
           this.setState({
            babyArr:res.data
           })
          }
        },
      })
    }
    //点击账单
    clickBills=()=>{
      let data = {}
      data = {
        params: [{
          // admID:"12055",
          admID:sessionStorage.patientData ? JSON.parse(sessionStorage.patientData).admID:"",
          userID:userData.userID
        }],
      }
      $http.post('urlS', this, {
        code: '05300012',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 ) {
           message.success(res.errorMessage)
          }
        },
      })
    }
    //点击查询---账单  左侧
    getBillsByMed = () => {
      // console.log("909090909",this.props.paras)
      this.props.form.validateFields((err, values) => {
        let { page, pageSize, } = this.state;
        let data = {}
        data = {
          params: [{
            patBillID:this.props.paras.patBillID || "",
            stDate: values.starData ? moment(values.starData).format('YYYY-MM-DD') : undefined,
            stTime: values.starTime ? moment(values.starTime).format('HH:mm:ss') : undefined,
            endDate: values.overData ? moment(values.overData).format('YYYY-MM-DD') : undefined,
            endTime: values.overTime ? moment(values.overTime).format('HH:mm:ss') : undefined,
            ordCatID: values.medicalAdviceGen,
            ordSubCatID: values.medicalAdviceSub,
            medID: this.state.rowIds,
            ordID: values.medicalAdviceDoctor,
            ordLocID: values.openingDepartment,
            amt: values.splitAmount,
            babyAdmID:this.state.babyId
          }],
          pagination: [{
            pageSize: pageSize,
            currentPage: page,
          }]
        }
        $http.post('urlS', this, {
          code: '05300006',
          data: data,
          success: function (res) {
            if (+res.errorCode === 0 && res.data) {
              if(res.alertInfo&&res.alertInfo){
                message.warning(res.alertInfo)
              }
              for (var i = 0; i < res.data.length; i++) {
                res.data[i].key = i 
              }
              if(res.data.length==0){
                this.setState({
                  disAdd:true
                })
               }
              this.setState({ leftData: res.data, total:res.total }, () => {
              })
            }
          },
        })
      })
    }
    //获取右侧已选数据
    getRightChecked=()=>{
      let { pageRight, pageSizeRight, } = this.state;
      let data = {}
      data = {
        params: [{
          patBillID:this.props.paras.patBillID || "",
        }],
        pagination: [{
          pageSize: pageSizeRight,
          currentPage: pageRight,
        }]
      }
      $http.post('urlS', this, {
        code: '05300007',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 && res.data) {
          res.data.map((item, i) => {
            res.data[i].key = i
            res.data[i]["updateUserID"] = userData.userID
          })
           this.setState({
            rightData:res.data,
            totalRight:res.total,
           })
           if(res.data.length==0){
            this.setState({
              disCancel:true
            })
           }
          }
        },
      })
    }
    //左侧 添加
    addBillsItem=(selectedRow_left)=>{
      let data = {}
      data = {
        params: selectedRow_left,
      }
      $http.post('urlS', this, {
        code: '05300008',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
            this.setState({
              selectedRowKeys_left:[],
              leftMoney:0,
              disAdd:true
            })
            this.getBillsByMed()
            this.getRightChecked()
          }
        },
      })
    }
    //右侧 取消添加 删除
    cancelBillsItem=()=>{
      let {selectedRow_right} = this.state
      let data = {}
      data = {
        params:selectedRow_right,
      }
      $http.post('urlS', this, {
        code: '05300009',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0) {
           this.setState({
            selectedRowKeys_right:[],
            rightMoney:0,
            disCancel:true,
           })
           this.getBillsByMed()
           this.getRightChecked()
          }
        },
      })
    }
      //确认拆分账单
      okSplitBills=()=>{
        let {rightData } = this.state;
        let data = {}
        data = {
          params: rightData,
        }
        $http.post('urlS', this, {
          code: '05300010',
          data: data,
          success: function (res) {
            if (+res.errorCode === 0) {
             message.success("拆分成功")
             //清空查询条件 table数据
             this.setState({
               selectedRowKeys_left:[],
               leftData:[],
               selectedRowKeys_right:[],
               rightData:[]
             })
          }
        }
        })
      }
    //医嘱项目搜索内容
    changeMedItemValue=(e)=>{
      this.setState({
        medItemValue:e.target.value
      })
    }
    //医嘱项目回车搜索
    searchMedItem=()=>{
      let {pageTop, pageSizeTop} = this.state
      let data = {}
      data = {
        params:[{
          unionValue:this.state.medItemValue,
        }],
        pagination: [{
          pageSize: pageSizeTop,
          currentPage: pageTop,
        }]
      }
      $http.post('urlS', this, {
        code: '05100169',
        data: data,
        success: function (res) {
          if (+res.errorCode === 0 &&res.data) {
            this.setState({
              visibleMedicalAdvice:true,
              medicalAdviceData:res.data,
              totalTop:res.total,
            })
          }
        },
      })
    }
    //医嘱项搜索弹出关闭
    closeCardPop=()=>{
      this.setState({
        visibleMedicalAdvice:false,
      })
      this.props.form.setFieldsValue({ medicalAdviceItems:undefined})
    }
    //医嘱项搜索页面信息带回
     setRowClassNames = (record) => {
      return record.medID === this.state.rowIds ? 'clickRowStyle' : '';
    }
    //选择孩子
    selectBaby=(value)=>{
      this.setState({
        babyId:value
      })
    }
    //点击Row 医嘱项表格
    onClickRow = (record) => {
      return {
        onClick: () => {
          if (this.state.rowId === "") {
            this.setState({
              rowIds: record.medID,
            });
          } else {
            if (this.state.rowId !== record.medID) {
              this.setState({
                rowIds: record.medID,
              });
            } else {
              this.setState({
                rowIds: "",
              });
            }
          }
        },
        onDoubleClick: () => {
          this.setState({
            visibleMedicalAdvice: false,
            rowIds: record.medID,
            })
            this.props.form.setFieldsValue({ medicalAdviceItems:record.medDesc})
        }
      };
    }
    //双击row 直接添加 左侧待选item
    chickLeftItem = (record)=>{
      let {selectedRow_left} = this.state
      return {
        onDoubleClick: () => {
          let arr = []
          arr.push(record)
          arr.map((item,i)=>{
            arr[i]["updateUserID"] = userData.userID
          })
          // console.log("arronDoc",arr)
           this.addBillsItem(arr)   
        }
      }
    }
    // 修改page和pageSize 跳转至---
    onChange = (page, pageSize) => {
      this.setState({ page: page, pageSize: pageSize }, () => {
        // 重新调用查询方法
        let { values } = this.state;
        this.getBillsByMed()
      })
    }
    //下拉选择页数
    onShowSizeChange = (page, pageSize) => {
      this.setState({ page: 1, pageSize: pageSize }, () => {
        // 重新调用查询方法
        let { values } = this.state;
        this.getBillsByMed()
      })
    }
    // 显示分页总条数
    showTotal(total) {
      return `共 ${total} 条`;
    }
     // 右侧-----
     // 修改page和pageSize 跳转至---
     onChangeRight = (pageRight, pageSizeRight) => {
      this.setState({ pageRight: pageRight, pageSizeRight: pageSizeRight }, () => {
        // 重新调用查询方法
        this.getRightChecked()
      })
    }
    //下拉选择页数
    onShowSizeChangeRight = (pageRightRight, pageSizeRight) => {
      this.setState({ pageRight: 1, pageSizeRight: pageSizeRight }, () => {
        // 重新调用查询方法
        this.getRightChecked()
      })
    }
    // 显示分页总条数
    showTotalRight(totalRight) {
      return `共 ${totalRight} 条`;
    }
    // 上方医嘱项-----
     // 修改page和pageSize 跳转至---
     onChangeTop = (pageTop, pageSizeTop) => {
      this.setState({ pageTop: pageTop, pageSizeTop: pageSizeTop }, () => {
        // 重新调用查询方法
        this.searchMedItem()
      })
    }
    //下拉选择页数
    onShowSizeChangeTop = (pageRightTop, pageSizeTop) => {
      this.setState({ pageTop: 1, pageSizeTop: pageSizeTop }, () => {
        // 重新调用查询方法
        this.searchMedItem()
      })
    }
    // 显示分页总条数
    showTotalTop(totalTop) {
      return `共 ${totalTop} 条`;
    }
 
  
    handleOk = (e) => {
      this.setState({ loading: true });
      setTimeout(() => {
        this.setState({ loading: false, visible: false });
      }, 3000);
    }
    render() {
      const { getFieldDecorator } = this.props.form;
      const { baseParms,medAGenArr,medASubArr,medADocArr,openDepArr,babyArr} = this.state;
      //医嘱大类
      let medAGenOp = []
      medAGenArr && medAGenArr.map(item => {
        medAGenOp.push(<Option key={item.id} disabled={item.disabled} value={item.id} title={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
      })
      //医嘱子类
      let medASubOp = []
      medASubArr && medASubArr.map(item => {
        medASubOp.push(<Option key={item.id} value={item.id}>{item.descripts}</Option>)
      })
     //医生医嘱 
      let medADocOp = []
      medADocArr && medADocArr.map(item => {
        medADocOp.push(<Option key={item.id} value={item.id} title={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
      })
     //开单科室
      let openDepOp = []
      openDepArr && openDepArr.map(item => {
        openDepOp.push(<Option key={item.id} value={item.id} title={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
      })
     //孩子们
      let childrenOp = []
        babyArr && babyArr.map(item => {
          childrenOp.push(<Checkbox key={item.admID} value={item.admID} >{item.patName}<span style={{
            borderRadius: "50%",
            width: "27px",
            height: "24px",
            display: "inline-block",
            background: (item.patSexDesc=="男"?"#40a9ff":"pink"),
            color: "#fff",
            textAlign: "center",
            fontSize: "12px",
            marginLeft:"4px",
            marginBottom:"8px",
            lineHeight: "24px"}}>{item.patSexDesc}</span></Checkbox>)
        })
       //左侧添加
       const medicalAdviceTableAdd = {
        selectedRowKeys: this.state.selectedRowKeys_left,
        onChange: (selectedRowKeys, selectedRows) => {
          let selectrow = "";
          if (selectedRowKeys.length === 0) {
            this.setState({
              disAdd:true
            })
          } else {
            selectrow = selectedRowKeys[selectedRowKeys.length - 1];
            this.setState({
              disAdd:false
            })
          }
          let money = 0
          selectedRows.map((item, i) => {
            selectedRows[i]["updateUserID"] = userData.userID
            money+=selectedRows[i].patBillMTotalAmt
          })
          // console.log("左侧点击后的",selectedRows,"arr",arr)
          this.setState({ selectrow: selectrow, selectedRow_left: selectedRows,leftMoney:money, selectedRowKeys_left: selectedRowKeys }, () => {
          });
        },
        onSelectAll: (selected, selectedRows, changeRows) => {
          let money = 0
          selectedRows.map((item, i) => {
            selectedRows[i]["updateUserID"] = userData.userID
            money+=selectedRows[i].patBillMTotalAmt
          })
          this.setState({selectedRow_left: selectedRows,leftMoney:money, });
        }
      };
       //右侧接收添加
       const medicalAdviceTableCancel = {
        selectedRowKeys: this.state.selectedRowKeys_right,
        onChange: (selectedRowKeys, selectedRows) => {
          let selectrow = "";
          if (selectedRowKeys.length === 0) {
            this.setState({
              disCancel:true
            })
          } else {
            selectrow = selectedRowKeys[selectedRowKeys.length - 1];
            this.setState({
              disCancel:false
            })
          }
          let money = 0
          selectedRows.map((item, i) => {
            selectedRows[i]["updateUserID"] = userData.userID
            money+=selectedRows[i].patBillMTotalAmt
          })
          this.setState({selectrow: selectrow, selectedRow_right: selectedRows,rightMoney:money, selectedRowKeys_right: selectedRowKeys }, () => {
          });
        },
        onSelectAll: (selected, selectedRows, changeRows) => {
          let money = 0
          selectedRows.map((item, i) => {
            selectedRows[i]["updateUserID"] = userData.userID
            money+=selectedRows[i].patBillMTotalAmt
          })
          this.setState({selectedRow_right: selectedRows,rightMoney:money });
        }
      };
      //医嘱项信息表格
      const columnsMedicalAdvice = [
        {
          key: 1,
          title: '编码',
          dataIndex: 'medCode',
          width: 50,
          align: 'center'
        }, {
          key: 2,
          title: '医嘱项名称',
          dataIndex: 'medDesc',
          width: 100,
          align: "center",
        }, {
          key: 3,
          title: '医嘱项子类',
          dataIndex: 'subCatDesc',
          width:100,
          align: "center",
        },]
      //主页面查询结果表格 左侧
      const columns = [
        {
          title: 'ID',
          dataIndex: 'splitBillID',
          width: 80,
          key: '0',
          align: "center",
        }, {
          title: '名称',
          dataIndex: 'medDesc',
          width: 200,
          align: "center",
          key: '1'
        }, {
          title: '执行信息',
          dataIndex: 'patCardTypeDesc',
          width: 100,
          align: "center",
          key: '2'
        }, {
          title: '单价',
          dataIndex: 'patBillMUnitPrice',
          width: 80,
          align: "center",
          key: '3'
        }, {
          title: '数量',
          dataIndex: 'patBillMQty',
          width: 60,
          align: "center",
          key: '4'
        }, {
          title: '金额',
          dataIndex: 'patBillMUnitPrice',
          width: 180,
          align: "center",
          key: '5'
        },]
      //主页面查询结果表格 左侧
      const columnsRight = [
        {
          title: 'ID',
          dataIndex: 'splitBillID',
          width: 80,
          key: '0',
          align: "center",
        }, {
          title: '名称',
          dataIndex: 'medDesc',
          width: 200,
          align: "center",
          key: '1'
        }, {
          title: '执行信息',
          dataIndex: 'patCardTypeDesc',
          width: 100,
          align: "center",
          key: '2'
        }, {
          title: '单价',
          dataIndex: 'patBillMUnitPrice',
          width: 80,
          align: "center",
          key: '3'
        },{
          title: '金额',
          dataIndex: 'patBillMUnitPrice',
          width: 180,
          align: "center",
          key: '4'
        },]
      return (
          <div style={{ padding: '4px 2px' }} className="aplitBillsDom">
          <div className="department-header">
          <div >
              <TipHeader userInfo={this.props.paras.userInfo} key={this.props.paras.userInfo.patID} />
          </div>
            <Form style={{margin:"0"}}>
            <Row gutter={60} style={{margin:"0"}}>
            <Col span={18} style={{padding:"0"}}>   
              <Row gutter={60} style={{ margin: '0' }}>
                <Col span={4} style={{paddingRight:"0px"}}>
                  <FormItem label='执行时间' wrapperCol={{ span: 15 }} labelCol={{ span: 8 }}>
                    {getFieldDecorator('starData', {
                      initialValue: undefined,
                      rules: [{ required: false, message: '' }],
                    })(
                        <DatePicker style={{ width: '100%' }} placeholder={'开始日期'} disabledDate={(curDate) => {
                            return curDate && curDate > moment().endOf('day');
                          }} />
                    )}
                  </FormItem>
                </Col>
                <Col span={2} style={{padding:"0px",width:"8%"}}>
                <FormItem wrapperCol={{ span: 24 }} labelCol={{ span: 8 }}>
                  <Col>
                    {getFieldDecorator('starTime', {
                    //   initialValue: info.parturientTime ? moment(info.parturientTime, 'HH:mm') : undefined,
                    })(
                      <TimePicker
                        style={{ width: '100%' }}
                        separator=":"
                        showToday
                        format={'HH:mm'}
                        // onOpenChange={this.handleOnOpenChangeStart}  
                        // onChange={this.clearValue.bind(this, "deliveryTime")}
                        placeholder="时间" />
                    )}
                  </Col>
                </FormItem>
                </Col>
                <Col span={1} style={{textAlign:"center",width: "2%",padding:"0"}}>
                <FormItem  wrapperCol={{ span: 24 }} labelCol={{ span: 3 }}>
                      <span>至</span>
                  </FormItem>
                </Col>
                <Col span={3} style={{padding:"0px",width:"10%"}}>
                  <FormItem  wrapperCol={{ span: 22 }} labelCol={{ span: 3 }}>
                    {getFieldDecorator('overData', {
                      initialValue: undefined,
                      rules: [{ required: false, message: '' }],
                    })(
                        <DatePicker style={{ width: '100%' }} placeholder={'结束日期'} disabledDate={(curDate) => {
                            return curDate && curDate > moment().endOf('day');
                          }} />
                    )}
                  </FormItem>
                </Col>
                <Col span={2} style={{padding:"0px",width:"8%"}}>
                <FormItem wrapperCol={{ span: 24 }} labelCol={{ span: 8 }}>
                  <Col>
                    {getFieldDecorator('overTime', {
                    //   initialValue: info.parturientTime ? moment(info.parturientTime, 'HH:mm') : undefined,
                    })(
                      <TimePicker
                        style={{ width: '100%' }}
                        separator=":"
                        showToday
                        format={'HH:mm'}
                        // onOpenChange={this.handleOnOpenChangeStart}  
                        // onChange={this.clearValue.bind(this, "deliveryTime")}
                        placeholder="时间" />
                    )}
                  </Col>
                </FormItem>
                </Col>
                <Col span={5} >
                  <FormItem label='医嘱大类' wrapperCol={{ span: 17 }} labelCol={{ span: 7 }}>
                    {getFieldDecorator('medicalAdviceGen', {
                      rules: [{ required: false, message: '' }],
                    })(
                      <Select showSearch allowClear placeholder="请选择医嘱大类" style={{ width: '100%' }}>
                        {medAGenOp}
                      </Select>
                    )}
                  </FormItem>
                </Col>
                <Col span={4} style={{padding:"0"}}>
                  <FormItem label='医嘱子类' wrapperCol={{ span: 17 }} labelCol={{ span: 7 }}>
                    {getFieldDecorator('medicalAdviceSub', {
                      rules: [{ required: false, message: '' }],
                    })(
                      <Select showSearch allowClear placeholder="请选择医嘱子类" style={{ width: '100%' }}>
                        {medASubOp}
                      </Select>
                    )}
                  </FormItem>
                </Col>
                <Col span={4} style={{padding:"0"}}>
                  <FormItem label='医嘱项' wrapperCol={{ span: 16 }} labelCol={{ span: 8 }}>
                    {getFieldDecorator('medicalAdviceItems', {
                      rules: [{ required: false, message: '' }],
                    })(
                      <Input placeholder="请输入医嘱项后回车" onChange={this.changeMedItemValue} onPressEnter={this.searchMedItem}></Input>
                    )}
                  </FormItem>
              </Col>
              </Row>
              <Row>
              <Col span={5} >
                  <FormItem label='医生医嘱' {...formItemLayoutDoctor}>
                    {getFieldDecorator('medicalAdviceDoctor', {
                      rules: [{ required: false, message: '' }],
                    })(
                      <Select showSearch allowClear placeholder="选择医生开立的医嘱" style={{ width: '100%' }}>
                        {medADocOp}
                      </Select>
                    )}
                  </FormItem>
                </Col>
                <Col span={6}>
                  <FormItem label='开单科室'  wrapperCol={{ span: 13 }} labelCol={{ span: 8 }}>
                    {getFieldDecorator('openingDepartment', {
                      rules: [{ required: false, message: '' }],
                    })(
                      <Select showSearch allowClear placeholder="请选择开单科室" style={{ width: '100%' }}>
                        {openDepOp}
                      </Select>
                    )}
                  </FormItem>
                </Col>
                <Col span={5}>
                  <FormItem label='指定拆分金额'wrapperCol={{ span: 12 }} labelCol={{ span: 8 }}>
                    {getFieldDecorator('splitAmount', {
                      rules: [{ required: false, message: '' }],
                      getValueFromEvent: (event) => {
                        return event.target.value.replace(/[^\d.]/g, '')
                    },
                      // 
                    })(
                      <Input type="number" min="0" prefix="￥"  placeholder="汇总后金额"></Input>
                    )}
                  </FormItem>
              </Col>  
              </Row>
              <Row>
                  <Col span={24} style={{textAlign:"right"}}>
                  <span style={{color:"rgb(64, 169, 255)",position: "absolute",left: "30px",top: "22px"}}>说明：查询仅针对左侧列表数据</span>
                  <FormItem rapperCol={{ span: 24 }} labelCol={{ span: 8 }}>
                    <Button type="primary" title="接口调试中" onClick={this.clickBills}>账单</Button>
                    <Button type="primary" onClick={this.getBillsByMed} style={{margin: "0 18px"}}>查询</Button> 
                    <Button type="primary" onClick={this.okSplitBills} disabled={this.state.rightData&&this.state.rightData.length==0?true:false}>确认拆分</Button>
                  </FormItem>
                </Col>
              </Row>
              </Col> 
              <Col span={6}>
                   <p style={{textAlign:"center",margin:"0",border: "1px solid #cfcfcf"}}><Icon type="smile" /><span style={{color:"#1999db",marginLeft:"4px"}}>孩子</span></p> 
                  <div style={{border: "1px solid #cfcfcf",maxHeight:"120px",height:"112px",padding: "6px 10px",overflow:"auto"}}>
                  <Col span={24} style={{padding:"0"}}>
                  <FormItem  wrapperCol={{ span: 24 }} labelCol={{ span: 8 }}>
                    {getFieldDecorator('childrens', {
                      rules: [{ required: false, message: '' }],
                    })(
                        <Checkbox.Group onChange={this.selectBaby} style={{display:"flex",width: "100%",flexWrap: "wrap"}}>
                            {childrenOp}
                        </Checkbox.Group>
                    )}
                  </FormItem>
              </Col>     
                  </div>
              </Col>
              </Row>
            </Form>
            </div>
            <Row gutter={60} style={{margin:"0",}}> 
                <Col span={12} style={{paddingLeft:"20px",paddingRight:"0px"}}>
                    <Card title="未结费用（待选）" bordered={false} style={{marginRight:"4px",}}>
                    <Row style={{marginBottom:"12px"}}>
                        <Button type="primary" disabled={this.state.disAdd} onClick={()=>this.addBillsItem(this.state.selectedRow_left)}>添加</Button>
                        <span style={{color:"green",position:"absolute",right:"0",bottom:"4px"}}>已选费用金额 ￥ {this.state.leftMoney}</span>
                    </Row>
                    <div>
                <Table
                    columns={columns}
                    dataSource={this.state.leftData}
                    pagination={false}
                    rowKey={record => record.key}
                    rowSelection={medicalAdviceTableAdd}
                    onRow={this.chickLeftItem}
                    bordered
                    style={{ height: store.getState().tableHeight.y - 40 + 'px' }}
                />
                {
                this.state.leftData&&this.state.leftData.length>0?<Pagination
                    showTotal={() => this.showTotal(this.state.total)}
                    size="small"
                    showQuickJumper
                    showSizeChanger
                    defaultCurrent={1}
                    current={this.state.page ? this.state.page : 1}
                    total={this.state.total ? this.state.total : 0}
                    onChange={this.onChange}
                    onShowSizeChange={this.onShowSizeChange}
                    style={{ textAlign: "right", marginTop: '9px', }}
                />:""
                }
                </div>
                </Card>
                </Col>
            <Col span={12} style={{paddingLeft:"0px",}}>
                <Card title="未结费用（已选）" bordered={false} style={{marginRight:"4px",}}>
                <Row style={{marginBottom:"12px"}}>
                    <Button type="primary" disabled={this.state.disCancel} onClick={this.cancelBillsItem}>取消添加</Button>
                    <span style={{color:"green",position:"absolute",right:"0",bottom:"4px"}}>已选费用金额 ￥ {this.state.rightMoney}</span>
                </Row>
            <div>
              <Table
                columns={columnsRight}
                dataSource={this.state.rightData}
                pagination={false}
                rowKey={record => record.key}
                rowSelection={medicalAdviceTableCancel}
                bordered                    
                style={{ height: store.getState().tableHeight.y - 40 + 'px' }}
                locale={{emptyText:(this.state.rightData&&this.state.rightData.length>0?"":<span>请在左侧添加需要拆分的费用后，点击<span style={{color:"rgb(64, 169, 255)",}}>"确认拆分"</span></span>)}}
              />
              {
               this.state.rightData&&this.state.rightData.length>0?<Pagination
                showTotal={() => this.showTotalRight(this.state.totalRight)}
                size="small"
                showQuickJumper
                showSizeChanger
                defaultCurrent={1}
                current={this.state.pageRight ? this.state.pageRight : 1}
                total={this.state.totalRight ? this.state.totalRight : 0}
                onChange={this.onChangeRight}
                onShowSizeChange={this.onShowSizeChangeRight}
                style={{ textAlign: "right", marginTop: '9px', }}
              />:""
              }
            </div>
            </Card>
            </Col>
            </Row>
            <Modal
              key='1'
              width='600px'
              visible={this.state.visibleMedicalAdvice}
              title="医嘱项"
              className="medicalDom"
              onCancel={this.closeCardPop}
              centered={true}
              footer={null}
              >
            <Table
                columns={columnsMedicalAdvice}
                dataSource={this.state.medicalAdviceData}
                rowKey={record => record.key}
                onRow={this.onClickRow}
                rowClassName={this.setRowClassNames}
                bordered
                style={{ marginTop: '12px' }}
                pagination={false}
            />
            {
               this.state.medicalAdviceData&&this.state.medicalAdviceData.length>0?<Pagination
                showTotal={() => this.showTotalTop(this.state.totalTop)}
                size="small"
                showQuickJumper
                showSizeChanger
                defaultCurrent={1}
                current={this.state.pageTop ? this.state.pageTop : 1}
                total={this.state.totalTop ? this.state.totalTop : 0}
                onChange={this.onChangeTop}
                onShowSizeChange={this.onShowSizeChangeTop}
                style={{ textAlign: "right", marginTop: '9px', }}
              />:""
              }
            </Modal>
          </div>
      )
    }
  })
export default SplitBills    